<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : test2.xsl
    Created on : 28. duben 2011, 21:21
    Author     : Martin Řehánek (rehan at mzk.cz)
    Description:
        Transforms tei to xml that contains for each element locus its path from root
        http://www.dpawson.co.uk/xsl/sect2/N6077.html#d5745e18
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:t="http://www.tei-c.org/ns/1.0"
                exclude-result-prefixes="t"
                version="1.0">
    <xsl:output method="xml"/>

    <xsl:template match="/t:TEI">
        <result>
            <xsl:for-each select="//t:locus">
                <locus>
                    <xsl:call-template name="print"/>
                </locus>
            </xsl:for-each>
        </result>
    </xsl:template>


    <xsl:template name="print">
<!--        <xsl:for-each select="ancestor-or-self::*">-->
        <xsl:for-each select="ancestor-or-self::*">
            <xsl:call-template name="print-step"/>
        </xsl:for-each>
        <xsl:apply-templates select="*"/>
    </xsl:template>

    <xsl:template name="print-step">
        <xsl:if test="self::*">
            <xsl:value-of select="name()"/>
            <xsl:text>:</xsl:text>
        </xsl:if>
    </xsl:template>

</xsl:stylesheet>
